package com.yisu.expressway.login;


import android.app.Activity;
import android.util.Log;

import com.yisu.expressway.R;
import com.yisu.expressway.activity.BaseActivity;
import com.yisu.expressway.application.ExApplication;
import com.yisu.expressway.utils.StringUtil;
import com.yisu.expressway.utils.ToastUtil;

/**
 * Created by theodore on 2016/9/20.
 */
public class ExInvalidUserListener implements OnInvlidUserListener {
    @Override
    public void onLogoutToLogin(String msg) {
        if (!StringUtil.isNullOrEmpty(msg)) {
            ToastUtil.displayLongToastMsg(ExApplication.getInstance().getApplicationContext(), msg);
        }

        LoginManager.onLogout();
        //最上面的activity就是LoginPageActivity，就不必再次启动它
        int size = BaseActivity.mActivityList.size();
        Activity topActivity = null;

        if (0 != size) {
            topActivity = BaseActivity.mActivityList.get(size - 1);
            if(topActivity.getClass() == LoginPageActivity.class) {
                return;
            }

            LoginPageActivity.launch(topActivity);
        }

    }
}
